#include "Image.h"

Image::Image() : data(nullptr)
{
}

Image::~Image()
{
    if (data != nullptr)
    {
        SDL_DestroyTexture(texture);
        SDL_FreeSurface(data);
        
    }
}

SDL_Surface *Image::getSurface()
{
    return data;
}

ImageDirect Image::getImageDirect()
{
    return imgdirect;
}

SDL_Texture *Image::getTexture(SDL_Renderer *renderer)
{
    if(texture==nullptr){
        return texture = SDL_CreateTextureFromSurface(renderer,getSurface());
    }
    return texture;
}

real Image::getAngle()
{
    switch (imgdirect)
    {
    case ImageDirect::DOWN:
        return 90;
    case ImageDirect::LEFT:
        return 90;
    case ImageDirect::UP:
        return -90;
    default:
        return 0;
    }
}
